import java.util.concurrent.CountDownLatch;

public class WaitingTask implements Runnable{
    private CountDownLatch cl;
    public WaitingTask(CountDownLatch cl){
        this.cl = cl;
    }
    public void run(){
        try{

            Long startTime = System.currentTimeMillis();
            System.out.println(Thread.currentThread().getName() + "总任务阻塞等待其他任务完成+++++++++++++");
            cl.await();
//            Thread.sleep(1000);

            Long endTime = System.currentTimeMillis();
            System.out.println("运行"+(endTime-startTime)/1000+"秒后，所有小任务完成。"+Thread.currentThread().getName() +"完成检查后结束++++++++++++++++++++");
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }


}
